﻿(function (angular) {

    angular.module("app.dictionary-grid")
        .controller("Word", Word);

    Word.$inject = ["wordData"];

    function Word(wordData) {
        var vm = this;

        setDefault();

        vm.clear = setDefault;
        vm.addWord = function (form) {
            if (form.$valid) {
                wordData.addWord(vm.word).then(function () {
                    setDefault();
                    alert("added");
                });
            }
        }

        function setDefault() {
            vm.word = {
                ForeignWord: "",
                Translation: "",
                Transcription: "",
                Description: ""
            };
        }
    };

})(angular)